package sg.edu.nus.iss.jass.persistence;

import java.util.Arrays;
import java.util.List;

import sg.edu.nus.iss.jass.datastore.BaseDAO;
import sg.edu.nus.iss.jass.datastore.exception.DataStoreException;
import sg.edu.nus.iss.jass.dto.Skill;
import sg.edu.nus.iss.jass.dto.SkillReference;

public class SkillDAO extends BaseDAO {

	public List<SkillReference> getAllSkills() throws DataStoreException {

		return selectAll(SkillReference.class);
	}
	
	public SkillReference getSkillRefById(String id) throws DataStoreException {

		return selectById(SkillReference.class, id);
	}
	
	public List<SkillReference> getSkillRefByIds(List<String> ids) throws DataStoreException {

		return selectByIds(SkillReference.class, ids.toArray(new String[0]));
	}

	public void saveSkills(Skill... skills) throws DataStoreException {

		if (skills!=null&&skills.length>0)
			saveObjects(Arrays.asList(skills));
	}
	
	public List<Skill> getSkillByIds(List<String> skillIDs) throws DataStoreException {
		return selectByIds(Skill.class, skillIDs.toArray(new String[0]));
	}
}
